package Main;

import java.io.IOException;

public class Test {

	public static void main2(String[] args) {
		try {
			//		Runtime.getRuntime().exec("cmd /C start cd C:\\Users\\admin\\Downloads\\mallet-2.0.6 /C echo aaa");
			//		System.out.println("AA");
			//		Runtime.getRuntime().exec("cmd /C bin\\mallet import-dir --input mydir --output data.mallet --keep-sequence --remove-stopwords");
			//		System.out.println("BB");
			//		Runtime.getRuntime().exec("cmd /C bin\\mallet train-topics --input data.mallet --num-topics 12 --num-iterations 10 --output-doc-topics topics.txt --num-top-words 6 --output-topic-keys keys.txt");
			//		System.out.println("CC");
			//		
			//		Runtime.getRuntime().exec("cmd /C dir *.*");  

			String pathOut="c:\\a\\";
			String pathIn="c:\\a\\web\\";
			String pathMallet="C:\\Users\\admin\\Downloads\\mallet-2.0.6\\";
			//		
			//		System.out.println("AA");
			//		Runtime.getRuntime().exec("cmd /c start "+pathMallet+"bin\\mallet import-dir --input "+pathIn+" --output "+pathOut+"data.mallet --keep-sequence --remove-stopwords");
			//		System.out.println("BB");
			//		Runtime.getRuntime().exec("cmd /c start "+pathMallet+"bin\\mallet train-topics --input "+pathOut+"data.mallet --num-topics 12 --num-iterations 10 --output-doc-topics "+pathOut+"topics.txt --num-top-words 6 --output-topic-keys "+pathOut+"keys.txt");
			//		System.out.println("CC");

			//		Process p = Runtime.getRuntime().exec("cmd /c "+pathMallet+"bin\\mallet import-dir --input "+pathIn+" --output "+pathOut+"data.mallet --keep-sequence --remove-stopwords");
			//			Process p2 = Runtime.getRuntime().exec("cmd /c "+pathMallet+"bin\\mallet train-topics --input "+pathOut+"data.mallet --num-topics 12 --num-iterations 10 --output-doc-topics "+pathOut+"topics.txt --num-top-words 6 --output-topic-keys "+pathOut+"keys.txt");

			Runtime r = Runtime.getRuntime();	
			Process p = r.exec("cmd /c "+pathMallet+"bin\\mallet import-dir --input "+pathIn+" --output "+pathOut+"data.mallet --keep-sequence --remove-stopwords");
			p.waitFor();
			System.out.println("done 1");
			p = r.exec("cmd /c "+pathMallet+"bin\\mallet train-topics --input "+pathOut+"data.mallet --num-topics 12 --num-iterations 10 --output-doc-topics "+pathOut+"topics.txt --num-top-words 6 --output-topic-keys "+pathOut+"keys.txt");
			p.waitFor();
			System.out.println("done 2");
			//			Process p = Runtime.getRuntime().exec("cmd /c");
			//System.out.println(p.getInputStream().read());
//			System.out.println(p.getOutputStream().getClass());
//			java.io.BufferedOutputStream b=(java.io.BufferedOutputStream)(p.getOutputStream());
//			b.write("/c dir\n".getBytes());
//			b.flush();
			//			BufferedWriter b1=new BufferedWriter(b);
			//			
//			BufferedReader in = new BufferedReader(  
//					new InputStreamReader(p.getInputStream()));  
//			String line = null;  
//			while ((line = in.readLine()) != null) {  
//				System.out.println(line); 
//			}
//			System.out.println("AAAAAAAAAAAAAAAAAA");


		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
